<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="zh">
<head>
    <title>教师信息|河海大学实践课程考勤系统</title>
    <jsp:include page="head.jsp"/>
    <script>
        function refreshVerifyCode() {
            document.getElementById("vcode").src = "${pageContext.request.contextPath}/checkCodeServlet?time=" + new Date().getTime();
        }

        function check() {
            var msg = document.getElementById("msg");
            if (document.getElementById("pwd").value !== document.getElementById("repeat_pwd").value) {
                msg.innerText = "密码不一致！";
                return false;
            }
            return true;
        }

        function toupdate() {
            var show = document.getElementById("show");
            var update = document.getElementById("update");
            show.style.display = "none";
            update.style.display = "block";
        }

        function toshow() {
            var show = document.getElementById("show");
            var update = document.getElementById("update");
            update.style.display = "none";
            show.style.display = "block";
        }
    </script>
</head>
<body>
<div class="container">
    <jsp:include page="header.jsp"/>
    <div class="row">
        <div class="col-sm-offset-1 col-sm-2">
            <ul class="nav nav-pills nav-stacked">
                <li><a href="${pageContext.request.contextPath}/teacher/index">主页</a></li>
                <li class="active"><a href="${pageContext.request.contextPath}/teacher/info">个人信息</a></li>
                <li><a href="${pageContext.request.contextPath}/teacher/addcourse">添加课程</a></li>
                <li><a href="${pageContext.request.contextPath}/teacher/logout">退出登录</a></li>
            </ul>
        </div>
        <div class="col-sm-offset-1 col-sm-6">
            <h3>个人信息</h3>
            <div id="show">
                <table class="table">
                    <tbody>
                    <tr>
                        <td>工号</td>
                        <td>${sessionScope.teacher.tid}</td>
                    </tr>
                    <tr>
                        <td>姓名</td>
                        <td> ${sessionScope.teacher.tname}</td>
                    </tr>
                    <tr>
                        <td>院系</td>
                        <td>${sessionScope.teacher.department}</td>
                    </tr>
                    </tbody>
                </table>
                <button class="btn btn-primary btn-block" onclick="toupdate()">修改信息或密码</button>
            </div>
            <div id="update" style="display: none;">
                <form class="form-horizontal" action="${pageContext.request.contextPath}/teacher/info" method="post"
                      onsubmit="return check()">
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="department">院系</label>
                        <div class="col-sm-10">
                            <input id="department" class="form-control" type="text" name="department"
                                   value="${sessionScope.teacher.department}" maxlength="32">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="pwd">新密码</label>
                        <div class="col-sm-10">
                            <input id="pwd" class="form-control" type="password" name="pwd" placeholder="留空则不修改密码" maxlength="32">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="repeat_pwd">重复新密码</label>
                        <div class="col-sm-10">
                            <input id="repeat_pwd" class="form-control" type="password" name="repeat_pwd" maxlength="32">
                        </div>
                    </div>
                    <p id="msg" class="text-danger text-center">${requestScope.msg}</p>
                    <div class="form-group">
                        <div class="col-sm-6">
                            <button class="btn btn-default btn-block" onclick="toshow()">取消</button>
                        </div>
                        <div class="col-sm-6">
                            <input class="btn btn-primary btn-block" type="submit" value="提交修改">
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <jsp:include page="footer.jsp"/>
</div>
</body>
</html>